<?php

$d = ($edit) ? $module->navigations_get($edit) : false;
$type = ($d) ? $d['type'] : 'int';

?>

<h1 class="<?php echo ($add) ? 'add' : 'edit'; ?>"><?php echo ($add) ? $lang->get('add-navigation') : $lang->get('edit-navigation'); ?></h1>

<form name="frm" method="post" action="<?php echo $cosa->system('base-url'); ?>/?m=<?php echo $m; ?>&s=<?php echo $s; ?>">
<input type="hidden" name="<?php echo ($add) ? 'add' : 'edit'; ?>" value="<?php echo ($add) ? '1' : $d['id']; ?>" />
<ul>
	<li><label for="title"><?php $lang->put('title'); ?></label>
		<input type="text" name="title" value="<?php if($d) echo stripslashes($d['title']); ?>" class="fld" />
	</li>
	<li>
		<label for="type"><?php $lang->put('nav-type'); ?></label>
		<select name="type" onchange="toggleDivsFromSelect(this); if(this.value == 'nav') { $('#par').hide(); } else { $('#par').show(); }">
			<option value="int"<?php if($type == 'int') echo ' selected="selected"'; ?>><?php $lang->put('nav-type-page'); ?></option>
			<option value="ext"<?php if($type == 'ext') echo ' selected="selected"'; ?>><?php $lang->put('nav-type-url'); ?></option>
			<option value="nav"<?php if($type == 'nav') echo ' selected="selected"'; ?>><?php $lang->put('nav-type-nav'); ?></option>
		</select>
		<ul style="margin-top: 10px;">
			<li id="int"<?php if($type != 'int') echo ' style="display:none;"'; ?>>
				<ul>
					<li><label for="page_id"><?php $lang->put('nav-type-page'); ?></label>
						<?php
						$value = ($d) ? $d['page_id'] : false;
						$module->printPagesDropdown('page_id', $value);
						?>
					</li>
				</ul>
			</li>
			<li id="ext"<?php if($type != 'ext') echo ' style="display:none;"'; ?>>
				<ul>
					<li><label for="ext_url"><?php $lang->put('nav-type-url'); ?></label>
						<input type="text" name="ext_url" value="<?php echo ($d) ? stripslashes($d['ext_url']) : 'http://'; ?>" class="fld" />
					</li>
					<li><label for="ext_target"><?php $lang->put('nav-urltar'); ?></label>
						<select name="ext_target" class="slct">
							<option value=""><?php $lang->put('nav-urltar-default'); ?></option>
							<option value="_blank" <?php if($d && $d['ext_target'] == '_blank') echo ' selected="selected"'; ?>><?php $lang->put('nav-urltar-blank'); ?></option>
							<option value="_parent" <?php if($d && $d['ext_target'] == '_parent') echo ' selected="selected"'; ?>><?php $lang->put('nav-urltar-parent'); ?></option>
							<option value="_self" <?php if($d && $d['ext_target'] == '_self') echo ' selected="selected"'; ?>><?php $lang->put('nav-urltar-self'); ?></option>
							<option value="_top" <?php if($d && $d['ext_target'] == '_top') echo ' selected="selected"'; ?>><?php $lang->put('nav-urltar-top'); ?></option>
						</select>
					</li>
				</ul>
			</li>
		</ul>
	</li>
	<li id="par"<?php if($type == 'nav') echo ' style="display:none;"'; ?>><label for="parent_id"><?php $lang->put('nav-parent-id'); ?></label>
		<?php
		$parent_id = ($d) ? $d['parent_id'] : false;
		$excl_id = ($d) ? $d['id'] : false;
		$module->printNavDropdown('parent_id', $parent_id, $excl_id);
		?>
	</li>
	<li><label for="weight"><?php $lang->put('nav-weight'); ?></label>
		<input type="text" name="weight" value="<?php if($d) echo stripslashes($d['weight']); ?>" class="fld small" />
	</li>
	<li class="sbmt">
		<input type="submit" value="<?php $lang->put('submit'); ?>" class="sbmt" />
		<?php if($d) $module->printDelLink($d['id'], false, $lang->get('del-page')); ?>
	</li>
</ul>
</form>
